﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;

using TTServer.Utilities;

using libReadWrite;
using libCommonClass;

namespace TTServer.Messages
{
    public class PPTOpenFileResponseMessage : TTMessage
    {
        private String _temporaryKey = "";

        public String TemporaryKey
        {
            get { return _temporaryKey; }
            set { _temporaryKey = value; }
        }

        private String _directory;

        public String Directory
        {
            get { return _directory; }
            set { _directory = value; }
        }

        private CFileInformation[] _fileInfos;

        public CFileInformation[] FileInfos
        {
            get { return _fileInfos; }
            set { _fileInfos = value; }
        }

        public PPTOpenFileResponseMessage()
        {

        }

        public PPTOpenFileResponseMessage(String temporaryKey, String directory, CFileInformation[] fis)
        {
            this.TemporaryKey = temporaryKey;
            this.Directory = directory;
            this.FileInfos = fis;
        }

        public override void ReadMessage(BigEndianReader sr)
        {
            throw new NotImplementedException();
        }

        public override void WriteMessage(BigEndianWriter sw)
        {
            sw.Write((byte) GetMessageID());

            sw.Write(Global.NO_LENGTH_CODE);

            sw.WriteString(this.TemporaryKey);
      
            sw.WriteString(this.Directory);

            sw.Write(this.FileInfos.Length);

            foreach (CFileInformation fileInfo in this.FileInfos)
            {
                sw.WriteString(fileInfo.path);
                sw.Write(fileInfo.type);
            }
        }

        public override TTMessage Clone()
        {
            return new PPTOpenFileResponseMessage();
        }

        public override int GetMessageID()
        {
            return MessageKind.PPT_OPEN_FILE_RESPONSE;
        }

        public override string GetMessageName()
        {
            return "PPTOpenFileResponseMessage";
        }
    }
}
